class HttpException extends Error {
    constructor(msg = '服务器错误', errCode = 10001, code = 400) {
        super()
        this.msg = msg
        this.errCode = errCode
        this.code = code
    }
}

class ParameterException extends HttpException {
    constructor(msg, errCode) {
        super()
        this.code = 400
        this.msg = msg || '参数错误'
        this.errCode = errCode || 10000
    }
}

class success extends HttpException {
    constructor(data = {}) {
        super()
        this.code = 200
        this.msg = data.msg || '操作成功'
        if (data.response)
            this.response = data.response
        if (data.total)
            this.total = data.total || 0
        this.errCode = data.errCode || 0
    }
}


class notFound extends HttpException {
    constructor(msg, errCode) {
        super()
        this.code = 404
        this.msg = msg || '参数错误'
        this.errCode = errCode || 10000
    }
}


module.exports = {
    HttpException,
    success,
    notFound,
    ParameterException
}